home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-06 | 3.4 KB | 103 lines | [TEXT/GEOL] |
- Item 5885612 23-Oct-90 14:53PDT
-
- From: MACDTS Macintosh Developer Tech Supt
-
- To: SATORI Satori SW, Hugh Rogovy,PRT
-
- cc: MACAPP.TECH$ MacApp Technical
-
- Sub: RE-TWindow.BuildWindowRgns bug
-
- Chris,
-
- Thanks for pointing this out. Yes, there does seem to be a problem with
- centering a window multiple times. However, the problem in not with
- BuildWindowRgns as you state, but with TWindow.Center. Center is smashing
- fContRgnInset. The change to fContRgnInset was cumulative, so that successive
- calls to TWindow.Center caused the window to move up and to the left more and
- more quickly. Your solution was to modify BuildWindowRgns to always rebuild
- fContRgnInset. However, this is not necessary with a correctly working
- TWindow.Center.
-
- In looking over TWindow.Center, I also noticed that it didn't take into account
- centering to devices other than the main device (this is also true with the
- modified version in the MacApp bugs technote, which fixes the problem of
- assuming the menubar is always 20 pixels high).
-
- I made two modifications to TWindow.Center that seems to get it working. First,
- I removed the instructions from "WITH globalbounds DO" to "{$POP}", inclusive;
- they are no longer used, and contain the code that was smashing fContRgnInset.
- Next, I reworked the formulas that calculate the topleft corner of the window.
- With a couple of other minor changes to help clean things up, the whole routine
- now looks like the following:
-
- PROCEDURE TWindow.Center(horizontally, vertically, forDialog: BOOLEAN);
-
- VAR
- windowSize: Point;
- screenSize: Point;
- globalbounds, screenRect: Rect;
- rgnsWereBuilt: BOOLEAN;
-
- BEGIN
- fHorzCentered := horizontally;
- fVertCentered := vertically;
- IF (fWMgrWindow <> NIL) & (horizontally | vertically) THEN
- BEGIN
- IF GetMaxIntersectedDevice(screenRect) = NIL THEN;
- WITH screenRect DO
- BEGIN
- screenSize.h := right - left;
- screenSize.v := bottom - top; { NOTE: GetMaxIntersectedDevice accounts
- for
- menubar so don't subtract gMbarHeight }
- END;
-
- rgnsWereBuilt := BuildWindowRgns(kBuild);
- WITH WindowPeek(fWMgrWindow)^.strucRgn^^.rgnBBox DO
- BEGIN
- windowSize.h := right - left;
- windowSize.v := bottom - top;
- END;
- IF BuildWindowRgns(rgnsWereBuilt) THEN; { discard result }
-
- GetGlobalBounds(globalbounds);
-
- WITH globalbounds DO
- BEGIN
- IF horizontally THEN
- left := screenRect.left { left of device }
- + (screenSize.h - windowSize.h) DIV 2 { total gray area left and right
- of window, divided by 2. }
- + fContRgnInset.h; { offset for position of portrect (which Locate wants)
- }
- IF vertically THEN
- IF forDialog THEN
- { Put it in the top third of the screen }
- top := screenRect.top { top of device }
- + (screenSize.v - windowSize.v) DIV 3 { total gray area above and below
- window, divided by 3. }
- + fContRgnInset.v { offset for position of portrect (which Locate wants)
- }
- ELSE
- top := screenRect.top { top of device }
- + (screenSize.v - windowSize.v) DIV 2 { total gray area above and below
- window, divided by 2. }
- + fContRgnInset.v; { offset for position of portrect (which Locate wants)
- }
- END;
- Locate(globalbounds.left, globalbounds.top, kDontInvalidate);
- END;
- END;
-
-
- If no one finds any problems with this, I'll put it in the MacApp bugs
- Technote.
-
-
- - Keith Rollin
- - Apple Developer Technical Support
-
-
-
-